home *** CD-ROM | disk | FTP | other *** search
/ AmigActive 21 / AACD 21.iso / AACD / Utilities / Ghostscript / src / std.h < prev    next >
Encoding:
C/C++ Source or Header  |  2001-01-01  |  12.6 KB  |  303 lines

  1. /* Copyright (C) 1989, 1992, 1993, 1994, 1995, 1998, 1999, 2000 Aladdin Enterprises.  All rights reserved.
  2.   
  3.   This file is part of AFPL Ghostscript.
  4.   
  5.   AFPL Ghostscript is distributed with NO WARRANTY OF ANY KIND.  No author or
  6.   distributor accepts any responsibility for the consequences of using it, or
  7.   for whether it serves any particular purpose or works at all, unless he or
  8.   she says so in writing.  Refer to the Aladdin Free Public License (the
  9.   "License") for full details.
  10.   
  11.   Every copy of AFPL Ghostscript must include a copy of the License, normally
  12.   in a plain ASCII text file named PUBLIC.  The License grants you the right
  13.   to copy, modify and redistribute AFPL Ghostscript, but only under certain
  14.   conditions described in the License.  Among other things, the License
  15.   requires that the copyright notice and this notice be preserved on all
  16.   copies.
  17. */
  18.  
  19. /*$Id: std.h,v 1.3 2000/09/19 19:00:51 lpd Exp $ */
  20. /* Standard definitions for Aladdin Enterprises code */
  21.  
  22. #ifndef std_INCLUDED
  23. #  define std_INCLUDED
  24.  
  25. #include "stdpre.h"
  26.  
  27. /* Include the architecture definitions. */
  28. #include "arch.h"
  29.  
  30. /*
  31.  * Define lower-case versions of the architecture parameters for backward
  32.  * compatibility.
  33.  */
  34. #define arch_align_short_mod ARCH_ALIGN_SHORT_MOD
  35. #define arch_align_int_mod ARCH_ALIGN_INT_MOD
  36. #define arch_align_long_mod ARCH_ALIGN_LONG_MOD
  37. #define arch_align_ptr_mod ARCH_ALIGN_PTR_MOD
  38. #define arch_align_float_mod ARCH_ALIGN_FLOAT_MOD
  39. #define arch_align_double_mod ARCH_ALIGN_DOUBLE_MOD
  40. #define arch_log2_sizeof_short ARCH_LOG2_SIZEOF_SHORT
  41. #define arch_log2_sizeof_int ARCH_LOG2_SIZEOF_INT
  42. #define arch_log2_sizeof_long ARCH_LOG2_SIZEOF_LONG
  43. #define arch_sizeof_ptr ARCH_SIZEOF_PTR
  44. #define arch_sizeof_float ARCH_SIZEOF_FLOAT
  45. #define arch_sizeof_double ARCH_SIZEOF_DOUBLE
  46. #define arch_float_mantissa_bits ARCH_FLOAT_MANTISSA_BITS
  47. #define arch_double_mantissa_bits ARCH_DOUBLE_MANTISSA_BITS
  48. #define arch_max_uchar ARCH_MAX_UCHAR
  49. #define arch_max_ushort ARCH_MAX_USHORT
  50. #define arch_max_uint ARCH_MAX_UINT
  51. #define arch_max_ulong ARCH_MAX_ULONG
  52. #define arch_cache1_size ARCH_CACHE1_SIZE
  53. #define arch_cache2_size ARCH_CACHE2_SIZE
  54. #define arch_is_big_endian ARCH_IS_BIG_ENDIAN
  55. #define arch_ptrs_are_signed ARCH_PTRS_ARE_SIGNED
  56. #define arch_floats_are_IEEE ARCH_FLOATS_ARE_IEEE
  57. #define arch_arith_rshift ARCH_ARITH_RSHIFT
  58. #define arch_can_shift_full_long ARCH_CAN_SHIFT_FULL_LONG
  59.  
  60. /* Define integer data type sizes in terms of log2s. */
  61. #define ARCH_SIZEOF_SHORT (1 << ARCH_LOG2_SIZEOF_SHORT)
  62. #define ARCH_SIZEOF_INT (1 << ARCH_LOG2_SIZEOF_INT)
  63. #define ARCH_SIZEOF_LONG (1 << ARCH_LOG2_SIZEOF_LONG)
  64. #define ARCH_INTS_ARE_SHORT (ARCH_SIZEOF_INT == ARCH_SIZEOF_SHORT)
  65. /* Backward compatibility */
  66. #define arch_sizeof_short ARCH_SIZEOF_SHORT
  67. #define arch_sizeof_int ARCH_SIZEOF_INT
  68. #define arch_sizeof_long ARCH_SIZEOF_LONG
  69. #define arch_ints_are_short ARCH_INTS_ARE_SHORT
  70.  
  71. /* Define whether we are on a large- or small-memory machine. */
  72. /* Currently, we assume small memory and 16-bit ints are synonymous. */
  73. #define ARCH_SMALL_MEMORY (ARCH_SIZEOF_INT <= 2)
  74. /* Backward compatibility */
  75. #define arch_small_memory ARCH_SMALL_MEMORY
  76.  
  77. /* Define unsigned 16- and 32-bit types.  These are needed in */
  78. /* a surprising number of places that do bit manipulation. */
  79. #if arch_sizeof_short == 2    /* no plausible alternative! */
  80. typedef ushort bits16;
  81. #endif
  82. #if arch_sizeof_int == 4
  83. typedef uint bits32;
  84. #else
  85. # if arch_sizeof_long == 4
  86. typedef ulong bits32;
  87. # endif
  88. #endif
  89.  
  90. /* Minimum and maximum values for the signed types. */
  91. /* Avoid casts, to make them acceptable to strict ANSI compilers. */
  92. #define min_short (-1 << (arch_sizeof_short * 8 - 1))
  93. #define max_short (~min_short)
  94. #define min_int (-1 << (arch_sizeof_int * 8 - 1))
  95. #define max_int (~min_int)
  96. #define min_long (-1L << (arch_sizeof_long * 8 - 1))
  97. #define max_long (~min_long)
  98.  
  99. /*
  100.  * The maximum values for the unsigned types are defined in arch.h,
  101.  * because so many compilers handle unsigned constants wrong.
  102.  * In particular, most of the DEC VMS compilers incorrectly sign-extend
  103.  * short unsigned constants (but not short unsigned variables) when
  104.  * widening them to longs.  We program around this on a case-by-case basis.
  105.  * Some compilers don't truncate constants when they are cast down.
  106.  * The UTek compiler does special weird things of its own.
  107.  * All the rest (including gcc on all platforms) do the right thing.
  108.  */
  109. #define max_uchar arch_max_uchar
  110. #define max_ushort arch_max_ushort
  111. #define max_uint arch_max_uint
  112. #define max_ulong arch_max_ulong
  113.  
  114. /* Minimum and maximum values for pointers. */
  115. #if arch_ptrs_are_signed
  116. #  define min_ptr min_long
  117. #  define max_ptr max_long
  118. #else
  119. #  define min_ptr ((ulong)0)
  120. #  define max_ptr max_ulong
  121. #endif
  122.  
  123. /* Define a reliable arithmetic right shift. */
  124. /* Must use arith_rshift_1 for a shift by a literal 1. */
  125. #define arith_rshift_slow(x,n) ((x) < 0 ? ~(~(x) >> (n)) : (x) >> (n))
  126. #if arch_arith_rshift == 2
  127. #  define arith_rshift(x,n) ((x) >> (n))
  128. #  define arith_rshift_1(x) ((x) >> 1)
  129. #else
  130. #if arch_arith_rshift == 1    /* OK except for n=1 */
  131. #  define arith_rshift(x,n) ((x) >> (n))
  132. #  define arith_rshift_1(x) arith_rshift_slow(x,1)
  133. #else
  134. #  define arith_rshift(x,n) arith_rshift_slow(x,n)
  135. #  define arith_rshift_1(x) arith_rshift_slow(x,1)
  136. #endif
  137. #endif
  138.  
  139. /*
  140.  * Standard error printing macros.
  141.  * Use dprintf for messages that just go to dstderr;
  142.  * dlprintf for messages to dsterr with optional with file name (and,
  143.  * if available, line number);
  144.  * eprintf for error messages to estderr that include the program name;
  145.  * lprintf for debugging messages that should include line number info.
  146.  * Since we intercept fprintf to redirect output under MS Windows,
  147.  * we have to define dputc and dputs in terms of fprintf also.
  148.  */
  149.  
  150. /*
  151.  * We would prefer not to include stdio.h here, but we need it for
  152.  * the FILE * argument of the printing procedures.
  153.  */
  154. #include <stdio.h>
  155.  
  156. /* dstderr and estderr may be redefined. */
  157. #define dstderr stderr
  158. #define estderr stderr
  159.  
  160. /* Print the program line # for debugging. */
  161. #if __LINE__            /* compiler provides it */
  162. void dprintf_file_and_line(P3(FILE *, const char *, int));
  163. #  define _dpl dprintf_file_and_line(estderr, __FILE__, __LINE__),
  164. #else
  165. void dprintf_file_only(P2(FILE *, const char *));
  166. #  define _dpl dprintf_file_only(estderr, __FILE__),
  167. #endif
  168.  
  169. void dflush(P0());        /* flush dstderr */
  170. #define dputc(chr) dprintf1("%c", chr)
  171. #define dlputc(chr) dlprintf1("%c", chr)
  172. #define dputs(str) dprintf1("%s", str)
  173. #define dlputs(str) dlprintf1("%s", str)
  174. #define dprintf(str)\
  175.   fprintf(dstderr, str)
  176. #define dlprintf(str)\
  177.   (_dpl dprintf(str))
  178. #define dprintf1(str,arg1)\
  179.   fprintf(dstderr, str, arg1)
  180. #define dlprintf1(str,arg1)\
  181.   (_dpl dprintf1(str, arg1))
  182. #define dprintf2(str,arg1,arg2)\
  183.   fprintf(dstderr, str, arg1, arg2)
  184. #define dlprintf2(str,arg1,arg2)\
  185.   (_dpl dprintf2(str, arg1, arg2))
  186. #define dprintf3(str,arg1,arg2,arg3)\
  187.   fprintf(dstderr, str, arg1, arg2, arg3)
  188. #define dlprintf3(str,arg1,arg2,arg3)\
  189.   (_dpl dprintf3(str, arg1, arg2, arg3))
  190. #define dprintf4(str,arg1,arg2,arg3,arg4)\
  191.   fprintf(dstderr, str, arg1, arg2, arg3, arg4)
  192. #define dlprintf4(str,arg1,arg2,arg3,arg4)\
  193.   (_dpl dprintf4(str, arg1, arg2, arg3, arg4))
  194. #define dprintf5(str,arg1,arg2,arg3,arg4,arg5)\
  195.   fprintf(dstderr, str, arg1, arg2, arg3, arg4, arg5)
  196. #define dlprintf5(str,arg1,arg2,arg3,arg4,arg5)\
  197.   (_dpl dprintf5(str, arg1, arg2, arg3, arg4, arg5))
  198. #define dprintf6(str,arg1,arg2,arg3,arg4,arg5,arg6)\
  199.   fprintf(dstderr, str, arg1, arg2, arg3, arg4, arg5, arg6)
  200. #define dlprintf6(str,arg1,arg2,arg3,arg4,arg5,arg6)\
  201.   (_dpl dprintf6(str, arg1, arg2, arg3, arg4, arg5, arg6))
  202. #define dprintf7(str,arg1,arg2,arg3,arg4,arg5,arg6,arg7)\
  203.   fprintf(dstderr, str, arg1, arg2, arg3, arg4, arg5, arg6, arg7)
  204. #define dlprintf7(str,arg1,arg2,arg3,arg4,arg5,arg6,arg7)\
  205.   (_dpl dprintf7(str, arg1, arg2, arg3, arg4, arg5, arg6, arg7))
  206. #define dprintf8(str,arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8)\
  207.   fprintf(dstderr, str, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8)
  208. #define dlprintf8(str,arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8)\
  209.   (_dpl dprintf8(str, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8))
  210. #define dprintf9(str,arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8,arg9)\
  211.   fprintf(dstderr, str, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9)
  212. #define dlprintf9(str,arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8,arg9)\
  213.   (_dpl dprintf9(str, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9))
  214. #define dprintf10(str,arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8,arg9,arg10)\
  215.   fprintf(dstderr, str, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10)
  216. #define dlprintf10(str,arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8,arg9,arg10)\
  217.   (_dpl dprintf10(str, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10))
  218. #define dprintf11(str,arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8,arg9,arg10,arg11)\
  219.   fprintf(dstderr, str, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10, arg11)
  220. #define dlprintf11(str,arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8,arg9,arg10,arg11)\
  221.   (_dpl dprintf11(str, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10, arg11))
  222. #define dprintf12(str,arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8,arg9,arg10,arg11,arg12)\
  223.   fprintf(dstderr, str, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10, arg11, arg12)
  224. #define dlprintf12(str,arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8,arg9,arg10,arg11,arg12)\
  225.   (_dpl dprintf12(str, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10, arg11, arg12))
  226.  
  227. void printf_program_ident(P3(FILE *f, const char *program_name,
  228.                  long revision_number));
  229. void eprintf_program_ident(P3(FILE *f, const char *program_name,
  230.                   long revision_number));
  231. const char *gs_program_name(P0());
  232. long gs_revision_number(P0());
  233.  
  234. #define _epi eprintf_program_ident(estderr, gs_program_name(),\
  235.                    gs_revision_number()),
  236.  
  237. #define eprintf(str)\
  238.   (_epi fprintf(estderr, str))
  239. #define eprintf1(str,arg1)\
  240.   (_epi fprintf(estderr, str, arg1))
  241. #define eprintf2(str,arg1,arg2)\
  242.   (_epi fprintf(estderr, str, arg1, arg2))
  243. #define eprintf3(str,arg1,arg2,arg3)\
  244.   (_epi fprintf(estderr, str, arg1, arg2, arg3))
  245. #define eprintf4(str,arg1,arg2,arg3,arg4)\
  246.   (_epi fprintf(estderr, str, arg1, arg2, arg3, arg4))
  247. #define eprintf5(str,arg1,arg2,arg3,arg4,arg5)\
  248.   (_epi fprintf(estderr, str, arg1, arg2, arg3, arg4, arg5))
  249. #define eprintf6(str,arg1,arg2,arg3,arg4,arg5,arg6)\
  250.   (_epi fprintf(estderr, str, arg1, arg2, arg3, arg4, arg5, arg6))
  251. #define eprintf7(str,arg1,arg2,arg3,arg4,arg5,arg6,arg7)\
  252.   (_epi fprintf(estderr, str, arg1, arg2, arg3, arg4, arg5, arg6, arg7))
  253. #define eprintf8(str,arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8)\
  254.   (_epi fprintf(estderr, str, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8))
  255. #define eprintf9(str,arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8,arg9)\
  256.   (_epi fprintf(estderr, str, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9))
  257. #define eprintf10(str,arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8,arg9,arg10)\
  258.   (_epi fprintf(estderr, str, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10))
  259.  
  260. #if __LINE__            /* compiler provides it */
  261. void lprintf_file_and_line(P3(FILE *, const char *, int));
  262. #  define _epl _epi lprintf_file_and_line(estderr, __FILE__, __LINE__),
  263. #else
  264. void lprintf_file_only(P2(FILE *, const char *));
  265. #  define _epl _epi lprintf_file_only(estderr, __FILE__)
  266. #endif
  267.  
  268. #define lprintf(str)\
  269.   (_epl fprintf(estderr, str))
  270. #define lprintf1(str,arg1)\
  271.   (_epl fprintf(estderr, str, arg1))
  272. #define lprintf2(str,arg1,arg2)\
  273.   (_epl fprintf(estderr, str, arg1, arg2))
  274. #define lprintf3(str,arg1,arg2,arg3)\
  275.   (_epl fprintf(estderr, str, arg1, arg2, arg3))
  276. #define lprintf4(str,arg1,arg2,arg3,arg4)\
  277.   (_epl fprintf(estderr, str, arg1, arg2, arg3, arg4))
  278. #define lprintf5(str,arg1,arg2,arg3,arg4,arg5)\
  279.   (_epl fprintf(estderr, str, arg1, arg2, arg3, arg4, arg5))
  280. #define lprintf6(str,arg1,arg2,arg3,arg4,arg5,arg6)\
  281.   (_epl fprintf(estderr, str, arg1, arg2, arg3, arg4, arg5, arg6))
  282. #define lprintf7(str,arg1,arg2,arg3,arg4,arg5,arg6,arg7)\
  283.   (_epl fprintf(estderr, str, arg1, arg2, arg3, arg4, arg5, arg6, arg7))
  284. #define lprintf8(str,arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8)\
  285.   (_epl fprintf(estderr, str, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8))
  286. #define lprintf9(str,arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8,arg9)\
  287.   (_epl fprintf(estderr, str, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9))
  288. #define lprintf10(str,arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8,arg9,arg10)\
  289.   (_epl fprintf(estderr, str, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10))
  290.  
  291. /*
  292.  * Define the prototype for module initialization procedures.  This is not
  293.  * a very good place to define this, but we can't find a better one.
  294.  */
  295. #ifndef gs_memory_DEFINED
  296. #  define gs_memory_DEFINED
  297. typedef struct gs_memory_s gs_memory_t;
  298. #endif
  299. #define init_proc(proc)\
  300.   int proc(P1(gs_memory_t *))
  301.  
  302. #endif /* std_INCLUDED */
  303.